/**
 * Mobile Vip qq.com
 * @author Levin
 * @version 1.0
 */
MFactory.M("demo",(function(){
	var p={},pub={};
	/* private methods
	++++++++++++++++++*/
	/**
	 * 页面导航模块
	 */
	p.navMod={
		vmn:null,//viewModNet instance
		lastView:null,//last viewMode
		cnt:0,
		init:function(){
			var me=this;
			me.vmn=new QST.viewModsNet('.page');
			me.instance=new QST.navMod({wrapperExp:'.nav_gb',itemsExp:'li',currentName:"current",viewModNet:me.vmn});
			me.cnt=me.instance.itemsExp.length;
			//override navMod's onBeforeEvent
			//建议QST.navMod支持事件模型或者通过option设置事件，这种覆盖的方式有点龊
			for(var i=0;i<me.cnt;i++){
				var item=me.instance.itemsExp[i];
				item.onBeforeEvent=function(doFocus){
					me.lastView=me.instance.currentEl;
					doFocus();
				};
			};
			//后退按钮事件注册
			me.initEvts();
		},//init
		initEvts:function(){
			var me=this;
			$(".btn_back").each(function(o,i){
				var e=function(){
					if(me.lastView){
						me.instance.focus(me.lastView);
					};					
				};
				me.instance.setEvent(o,"click",e);
			});
		}
	};
	/* public methods
	++++++++++++++++++*/
	pub.init=function(opts){
		//document.addEventListener('touchmove',function(e){e.preventDefault();},false);
	};
	/**
	 * 页面加载完毕后执行的逻辑
	 */
	pub.onLoad=function(){
		p.navMod.init();
	};
	return pub;
})());